﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Teradata.Client.Provider;
using System.Configuration;
using System.Data;
using System.Threading;

public partial class TracReports : System.Web.UI.Page
{

    protected String CurrProdLine = String.Empty, CurrProd = String.Empty;
    protected Int32 SUB_MTD_CNT = 0, SUB_PREV_MTD_CNT = 0, SUB_PREV_MON = 0, SUB_PACING_CNT = 0;
    protected Int32 TOT_MTD_CNT = 0, TOT_PREV_MTD_CNT = 0, TOT_PREV_MON = 0, TOT_PACING_CNT = 0;

    public string sStreetAddr = "";

    public Addresses Addrs;
    protected String Address;

    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");

        if (Request.QueryString["TRAC_ID"] != null)
        {
            if (RollUpReport1 != null)
            {
                RollUpReport1.RollUpUnit = Request.QueryString["TRAC_ID"].Trim();
                RollUpReport1.RollupTitle = Request.QueryString["Title"].Trim().Split(':')[0];
                Session["RollupTitle"] = RollUpReport1.RollupTitle;
                Session["TRAC_ID"] = RollUpReport1.RollUpUnit;
            }

            if (!IsPostBack)
            {
                ////Get the MTD_SALES data
                ////DisplayGrid.DataSource = (new RolledUpBiz()).MTD_Sales(RollUpReport1.RollUpUnit);
                ////DisplayGrid.DataBind();
            Addrs = new Addresses();
            hdnAddress.Value = Addrs.GetLocation(ref sStreetAddr);
            //Addrs.LoadAddressList(ref grvAddressList, Request.QueryString["TRAC_ID"].ToString());
 
                MTD_Sales1.RollUpUnit = RollUpReport1.RollUpUnit;
                MTD_Sales1.RollupTitle = RollUpReport1.RollupTitle;
                MTD_Sales1.TopLevel = "TRAC_ID";

                //Channels1.RollUpUnit = RollUpReport1.RollUpUnit;
                //Channels1.RollupTitle = RollUpReport1.RollupTitle;
                //Channels1.TopLevel = MTD_Sales1.TopLevel;
           }
        }

        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString());
    }


     protected void AddressList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        System.Web.UI.WebControls.WebControl lbl = (System.Web.UI.WebControls.WebControl)(e.Row.Cells[0].FindControl("lblAddr"));
        if (lbl != null)
        {
            System.Drawing.Color bc = lbl.BackColor;
            Addrs.CountBlue += bc == System.Drawing.ColorTranslator.FromHtml("#47CAFF") ? 1 : 0;
            Addrs.CountGreen += bc == System.Drawing.ColorTranslator.FromHtml("#a4f368") ? 1 : 0;
            Addrs.CountWhite += bc == System.Drawing.ColorTranslator.FromHtml("#FFFFFF") ? 1 : 0;
        }
    }





}